home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / ebl.arc / BATDEMO.BAT < prev    next >
Encoding:
DOS Batch File  |  1985-11-12  |  10.1 KB  |  260 lines

  1. bat * Begin Batch Language Demo * (C)opyright by Seaware Corp. 1982, 1983
  2. bat *                             (C)opyright by Frank Canova  1982, 1983
  3.  
  4. bat * Send contributions to: Seaware Corp.
  5. bat *                        P.O. Box 1656
  6. bat *                        Delray Beach, FL 33444
  7.  
  8. bat * Caution: never transfer this file on a communication line via 7-bit ASCII
  9.  
  10. bat *---- FEATURES OF THE LANGUAGE USED WITHIN THIS DEMO ARE: ----------------
  11. bat * Standary DOS commands can be intermixed freely with BAT commands.
  12. bat * Like basic, putting things at top is quicker for goto's / loops to find.
  13. bat * Up to 15 chars are allowed for labels, contents of vars, and literals
  14. bat * 10 variables are provided to be passed to/from DOS. They're %0 to %9.
  15. bat * 15 variables are provided for user use only. They're %A to %O.
  16. bat * The variable %R is a return code that any routine can set at [0:04FE]
  17. bat * Note that 'BEGTYPE' & 'BEGSTACK' do not do variable substitution.
  18. bat * BEGTYPE  command can have screen attributes via a '\hex' format.
  19. bat * BEGSTACK command can have timing attributes via a '\hex' format.
  20. bat * Spaces are needed to delimit operators.
  21. bat * Non-spaces will concatenate variables and literals.
  22. bat * STATEOF sets return code based on state of files existance.
  23.  
  24. bat cls begtype
  25. ╔════════════════════════════════════════════════════════════════════════╗
  26. ║             (C)opyright by Seaware Corp. 1982, 1983                    ║
  27. ║             (C)opyright by Frank Canova  1982, 1983                    ║
  28. ║                                                                        ║
  29. ║  This is User Supported Software ::                                    ║
  30. ║                                                                        ║
  31. ║  You  are encouraged to  copy and share this program with other users, ║
  32. ║  on the  conditions that the program is not  distributed  in  modified ║
  33. ║  form, that no fee or consideration is charged, and that this notice   ║
  34. ║  is not bypassed or removed.                                           ║
  35. ║                                                                        ║
  36. ║  PRIVATE USERS, If you are using this program and finding it of value, ║
  37. ║          your contribution ($30 suggested) will be appreciated.        ║
  38. ║                                                                        ║
  39. ║  The $30 license fee (per system) is required for COMMERCIAL USERS if  ║
  40. ║          used in a place of business or put into another product.      ║
  41. ║                                                                        ║
  42. ║                    Seaware Corp.                                       ║
  43. ║                    P.O. Box 1656                                       ║
  44. ║                    Delray Beach, FL 33444                              ║
  45. ║                                                                        ║
  46. ╚════════════════════════════════════════════════════════════════════════╝
  47.  
  48. End
  49. bat type What is your first name? ==> ;
  50. bat read %8
  51. bat %7 = 27
  52. bat %L =
  53. bat goto -top
  54.  
  55. bat * number guessing demo *
  56. bat -i.can.count %6 = 5
  57.    bat cls type i am thinking of a two digit number, can you guess it?
  58.    bat -c.loop read %5
  59.    bat if %5 = %7 skip 7
  60.    bat %6 = %6 - 1
  61.    bat if %6 <> 0 skip 2
  62.        bat type boo hisss! the number was %7!
  63.        bat skip 4
  64.    bat if %5 > %7 type try a little lower. you only get %6 more tries.
  65.    bat if %5 < %7 type try a higher number. you get %6 more tries.
  66.    bat goto -c.loop
  67.    bat type great! i was afraid you weren't going to get it!
  68.    bat begtype
  69.  
  70. A BAT program can create loops and count events. With this you can
  71. sequence through file numbers, or create loops to do retrys in case of
  72. errors. In addition, BAT programs can do simple arithmetic and string
  73. manipulation.
  74.  
  75. (press any key to continue)
  76. end
  77. bat inkey
  78.  
  79. bat -top cls type ======== %8's extended batch sampler menu ===========
  80. bat begtype
  81.  
  82.       \0FC\07 - I can Count
  83.  
  84.       \0fD\07 - Directory of available programs
  85.  
  86.       \0fF\07 - Testing for files
  87.  
  88.       \0fK\07 - Keyboard stack (the invisible fingers)
  89.  
  90.       \0fS\07 - Display Screen and String operations
  91.  
  92.       \0fX\07 - Exit
  93.  
  94.  
  95. Select an option.
  96. end
  97. bat -entry read %9
  98. bat %7 = %7 + 3
  99. bat * Skiping is quicker than goto's, but only goes forward.
  100. bat if %9 <> d goto -not.d
  101.     bat type enter file.spec for files you would like to see, or press ENTER for all.
  102.     bat read %1
  103.     bat if .%1 = . %1 = *.*
  104.     bat -dirques type Would you like a (S)tandard or (W)ide directory?
  105.     bat inkey %2 | %m = %2 # | if %m = 1 type %2
  106.     bat * Notice you can chain togeather if's, like . . .
  107.     bat if %2 <> s if %2 <> w goto -dirques
  108.     bat %3 =
  109.     bat if %2 = w %3 = /w
  110.     bat cls
  111.     rem       (notice that two parms are passed to dos here. %%1 and %%3)
  112.     dir %1 %3
  113.     bat * Returning to Extended Batch demo *
  114.     bat begtype
  115.  
  116. This directory was created by using a DOS command within this batch file. Any
  117. DOS command can be mixed freely within lines of the BAT program. By passing
  118. parameters to/from DOS, you can have complete control of how a program
  119. operates. User programs may also set a return code in order to control the
  120. execution of the BAT batch file program.
  121.  
  122.     Press any key to continue. . .
  123. end
  124.     bat inkey
  125.     bat goto -top
  126.  
  127. bat -not.d if %9 <> x skip 3
  128.     bat type so long %8....
  129.     bat type p.s. for quickie help, just enter 'bat' from dos.
  130.     bat exit
  131.  
  132. bat if %9 = c goto -i.can.count
  133.  
  134. bat if %9 <> f goto -not.f
  135.     bat type enter a file name for me to search for.
  136.     bat read %9
  137.     bat type scanning for file: %9 . . .
  138.     bat stateof %9 * this will set the return code up (%R)
  139.     bat if %r <> 0 skip 2
  140.     bat    type the file does exist - exactly as typed.
  141.     bat    skip 7
  142.     bat if %r <> 1 skip 2
  143.     bat    type the file does not exist on any drive.
  144.     bat    skip 5
  145.     bat if %r <> 9 skip 2
  146.     bat    type the file name given is invalid.
  147.     bat    skip 2
  148.     bat type the file does exist - but was found on the %r drive.
  149.     bat type to properly find this file, the complete filename would be %9
  150.     bat begtype
  151.  
  152.        File searching is done by a command called STATEOF.
  153.  
  154. If the file was there, we could direct a program to use it, even if it wasn't
  155. on the specific diskette drive that the operator was expecting.
  156.  
  157. If the file was not there, we could have printed out an error message to the
  158. operator, or we could have run an alternate program in order to create the
  159. missing file.
  160.  
  161. Press any key to continue . . .
  162. end
  163.     bat inkey
  164.     bat goto -top
  165.  
  166. bat -not.f if %9 <> k goto -not.k
  167.     bat cls begtype
  168. ╔═════════════════════════════════════════════════════════════════════════════╗
  169. ║                                                                             ║
  170. ║       The keyboard stack can answer questions to programs automatically.    ║
  171. ║       For example, this DOS command can be responded to from the stack.     ║
  172. ║                                                                             ║
  173. ╚═════════════════════════════════════════════════════════════════════════════╝
  174. end
  175.     bat begstack
  176. This text is actually being typed for you from the keyboard stack.
  177. All keys, including control keys and function keys can come from this stack.
  178. Keystrokes can \ff\10even \ff\10have \ff\10delayed \ff\10typing.
  179. \1a
  180. end
  181. rem ... Below is the DOS command that will read the keyboard stack.
  182. copy con: nul:
  183. bat *returning from DOS command*
  184. bat begtype
  185.  
  186. (press any key to continue)
  187. end
  188. bat inkey
  189. bat goto -top
  190.  
  191. bat -not.k if %9 <> s goto -not.s
  192.     bat cls begtype
  193. ╔═════════════════════════════════════════════════════════════════════════════╗
  194. ║                                                                             ║
  195. ║       All sorts of screen attributes can be printed on the screen.          ║
  196. ║                                                                             ║
  197. ║   On monochrome display you see:            On color display you see:       ║
  198. ╚═════════════════════════════════════════════════════════════════════════════╝
  199.  
  200.         \04Normal                               Red on Black  \07
  201.         \0fHigh Intensity                       High Intensity\07
  202.         \21Underlined                           Blue on Green \07
  203.         \85Flashing Normal                      Flashing Magenta on Black\07
  204.  
  205.                 And \0fmany\07 other combinations!
  206.  
  207.  
  208. \1b[33;44m Users of DOS 2.0 ANSI.SYS can also control the display. \1b[0m
  209.  
  210.  
  211.                 (press any key to continue)
  212. end
  213.     bat inkey
  214.     bat cls
  215.     bat -rd.name1 if .%8 <> . skip 3
  216.     bat   type i didn't catch your first name, what was it?
  217.     bat   read %8
  218.     bat   goto -rd.name1
  219.     bat type i know that your first name is %8
  220.     bat -rd.name2 if .%L <> . skip 3
  221.     bat   type i didn't catch your last name, what was it?
  222.     bat   read %L
  223.     bat   goto -rd.name2
  224.     bat type
  225.     bat type i am using your name as two strings to work with.
  226.     bat type
  227.     bat type comparisons can be made . . .
  228.     bat if %8 = %L type the strings are equal.
  229.     bat if %8 <> %L type the strings are not equal.
  230.     bat * notice a '.' will make sure that null entries can be found
  231.     bat type
  232.     bat type Strings contents can be manipulated . . .
  233.     bat type CONCATENATION.. They can be combined to form %8%L
  234.     bat type CONCATENATION.. or to form %L%8.
  235.     bat %I = %8 $ 1 1
  236.     bat %I = %I.%L $ 1 3
  237.     bat %H = %8 #
  238.     bat type SUBSTRINGS..... Your initials would be %I.
  239.     bat type LENGTHS........ Your first name has %H letters.
  240.     bat begtype
  241.  
  242.  Strings will be truncated at 15 characters and may be passed back
  243.  and forth from DOS. There are 10 variables for strings which may
  244.  operate with DOS, and 15 which can be used even between
  245.  executing BAT programs. There are another 5 variables which
  246.  have predefined (fixed) contents to give status, etc. String operations
  247.  and comparisons can be done as well.
  248.  
  249. (Press any key to continue)
  250. end
  251.     bat inkey
  252.     bat goto -top
  253.  
  254. bat -not.s BEGTYPE
  255.  
  256. You did not select a valid option.
  257. Press \0FC, D, F, S or X\07.
  258. END
  259. bat goto -entry
  260.